<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
/**
 * 控制器创建: php artisan make:controller Admin/UpfilesController
 */
class UpfilesController extends Controller
{
    //在config/filesystems.php文件设置上传文件为uploads文件
    public function upimages(Request $request)
    {
        if($request->isMethod('post')){
            if($request->file('file')){
                $files = $request->post('files');
                $url = $request->file('file')->store($files);
                return response()->json(['code' => 1, 'msg' => '上传成功!','src'=>$url]);
                //dump($url);
            }else{
                // 上传失败获取错误信息
                return response()->json(['code' => 0, 'msg' => '上传文件不能为空!']);
            }
        }
    }
}
